package leetcode.code0455;

import java.util.Arrays;

public class Solution {
	public int findContentChildren(int[] g, int[] s) {
		Arrays.sort(g);
		Arrays.sort(s);
		int ans = 0;
		for (int i = 0, j = 0; i < g.length && j < s.length; i++) {
			int cur = g[i];
			while (j < s.length && s[j] < cur) {
				j++;
			}
			if (j < s.length && s[j] >= cur) {
				ans++;
				j++;
			}
		}
		return ans;
	}
}
